package com.zt.student.controller;

import com.zt.student.dto.HomeworkWithClassDTO;
import com.zt.common.pojo.common.JsonResult;
import com.zt.student.dto.HomeworkDTO;
import com.zt.student.service.HomeworkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * description:
 * author:zt
 * date:2022-02-12
 */
@RestController
@CrossOrigin
@RequestMapping("homework")
@Api("作业模块")
public class HomeworkController {

    @Autowired
    private HomeworkService homeworkService;

    @GetMapping("getByClassId/{classId}")
    @ApiOperation("根据班级id获取该学生该班级作业情况")
    public JsonResult<List<HomeworkDTO>> getByClassId(HttpServletRequest request, @PathVariable int classId){
        return JsonResult.success(homeworkService.getByClassId(request,classId));
    }

    @GetMapping("getBySemester/{semester}")
    @ApiOperation("根据学期获取该学生该学期的所有作业情况")
    public JsonResult<List<HomeworkWithClassDTO>> getBySemester(HttpServletRequest request, @PathVariable String semester){
        return JsonResult.success(homeworkService.getBySemester(request,semester));
    }
}
